{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4e773cdd",
   "metadata": {},
   "source": [
    "---\n",
    "* 2023.9.20\n",
    "* 课程：python\n",
    "* week03\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f9dcdd1e",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "## 1. 模块与函数\n",
    "## 2. 变量、赋值、数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a91cc7f",
   "metadata": {},
   "source": [
    "## 1.模块\n",
    "### 1.1 标准库\n",
    "### 1.2 开源模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1ab343e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 标准库实践\n",
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1ec42fe7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'win32'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.platform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cfd33f4f",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'time' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[6], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m time\u001b[38;5;241m.\u001b[39mlocaltime\n",
      "\u001b[1;31mNameError\u001b[0m: name 'time' is not defined"
     ]
    }
   ],
   "source": [
    "time.localtime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3b41416b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0b3ce00c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2023, tm_mon=11, tm_mday=12, tm_hour=23, tm_min=13, tm_sec=50, tm_wday=6, tm_yday=316, tm_isdst=0)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9c1d1342",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'pyecharts'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[9], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# 开源模块实践\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpyecharts\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pyecharts'"
     ]
    }
   ],
   "source": [
    "# 开源模块实践\n",
    "import pyecharts"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fcbec0c9",
   "metadata": {},
   "source": [
    "* 笔记\n",
    "下载安装开源模块方法：pip install module_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "cb35dd04",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting pyecharts\n",
      "  Obtaining dependency information for pyecharts from https://files.pythonhosted.org/packages/88/9c/213d7107634fb6629a932f9120ec78be04435eabd1b2bee482908ac9d648/pyecharts-2.0.4-py3-none-any.whl.metadata\n",
      "  Downloading pyecharts-2.0.4-py3-none-any.whl.metadata (1.3 kB)\n",
      "Requirement already satisfied: jinja2 in d:\\anaconda3\\lib\\site-packages (from pyecharts) (3.1.2)\n",
      "Collecting prettytable (from pyecharts)\n",
      "  Obtaining dependency information for prettytable from https://files.pythonhosted.org/packages/4d/81/316b6a55a0d1f327d04cc7b0ba9d04058cb62de6c3a4d4b0df280cbe3b0b/prettytable-3.9.0-py3-none-any.whl.metadata\n",
      "  Downloading prettytable-3.9.0-py3-none-any.whl.metadata (26 kB)\n",
      "Collecting simplejson (from pyecharts)\n",
      "  Obtaining dependency information for simplejson from https://files.pythonhosted.org/packages/b6/8e/3e12d122dfdf549a8d12eaf39954ee39f2027060aa38b63430f8ab3244e7/simplejson-3.19.2-cp311-cp311-win_amd64.whl.metadata\n",
      "  Downloading simplejson-3.19.2-cp311-cp311-win_amd64.whl.metadata (3.2 kB)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in d:\\anaconda3\\lib\\site-packages (from jinja2->pyecharts) (2.1.1)\n",
      "Requirement already satisfied: wcwidth in d:\\anaconda3\\lib\\site-packages (from prettytable->pyecharts) (0.2.5)\n",
      "Downloading pyecharts-2.0.4-py3-none-any.whl (147 kB)\n",
      "   ---------------------------------------- 0.0/147.7 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/147.7 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/147.7 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/147.7 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/147.7 kB ? eta -:--:--\n",
      "   -- ------------------------------------- 10.2/147.7 kB ? eta -:--:--\n",
      "   -- ------------------------------------- 10.2/147.7 kB ? eta -:--:--\n",
      "   -- ------------------------------------- 10.2/147.7 kB ? eta -:--:--\n",
      "   -------- ------------------------------ 30.7/147.7 kB 146.3 kB/s eta 0:00:01\n",
      "   -------- ------------------------------ 30.7/147.7 kB 146.3 kB/s eta 0:00:01\n",
      "   -------- ------------------------------ 30.7/147.7 kB 146.3 kB/s eta 0:00:01\n",
      "   ---------- ---------------------------- 41.0/147.7 kB 122.9 kB/s eta 0:00:01\n",
      "   ---------- ---------------------------- 41.0/147.7 kB 122.9 kB/s eta 0:00:01\n",
      "   --------------------- ----------------- 81.9/147.7 kB 199.7 kB/s eta 0:00:01\n",
      "   --------------------- ----------------- 81.9/147.7 kB 199.7 kB/s eta 0:00:01\n",
      "   --------------------- ----------------- 81.9/147.7 kB 199.7 kB/s eta 0:00:01\n",
      "   --------------------- ----------------- 81.9/147.7 kB 199.7 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ------------------------ -------------- 92.2/147.7 kB 154.3 kB/s eta 0:00:01\n",
      "   ---------------------------- --------- 112.6/147.7 kB 109.3 kB/s eta 0:00:01\n",
      "   ---------------------------- --------- 112.6/147.7 kB 109.3 kB/s eta 0:00:01\n",
      "   ---------------------------- --------- 112.6/147.7 kB 109.3 kB/s eta 0:00:01\n",
      "   ---------------------------- --------- 112.6/147.7 kB 109.3 kB/s eta 0:00:01\n",
      "   ---------------------------- --------- 112.6/147.7 kB 109.3 kB/s eta 0:00:01\n",
      "   -------------------------------- ------ 122.9/147.7 kB 98.8 kB/s eta 0:00:01\n",
      "   -------------------------------- ------ 122.9/147.7 kB 98.8 kB/s eta 0:00:01\n",
      "   -------------------------------- ------ 122.9/147.7 kB 98.8 kB/s eta 0:00:01\n",
      "   -------------------------------- ------ 122.9/147.7 kB 98.8 kB/s eta 0:00:01\n",
      "   ------------------------------------- - 143.4/147.7 kB 98.0 kB/s eta 0:00:01\n",
      "   -------------------------------------- 147.7/147.7 kB 100.0 kB/s eta 0:00:00\n",
      "Downloading prettytable-3.9.0-py3-none-any.whl (27 kB)\n",
      "Downloading simplejson-3.19.2-cp311-cp311-win_amd64.whl (75 kB)\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ---------------------------------------- 0.0/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ----- ---------------------------------- 10.2/75.3 kB ? eta -:--:--\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   ---------------- ----------------------- 30.7/75.3 kB 34.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   --------------------- ------------------ 41.0/75.3 kB 20.5 kB/s eta 0:00:02\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------- ------- 61.4/75.3 kB 25.0 kB/s eta 0:00:01\n",
      "   -------------------------------------- - 71.7/75.3 kB 24.7 kB/s eta 0:00:01\n",
      "   ---------------------------------------- 75.3/75.3 kB 26.2 kB/s eta 0:00:00\n",
      "Installing collected packages: simplejson, prettytable, pyecharts\n",
      "Successfully installed prettytable-3.9.0 pyecharts-2.0.4 simplejson-3.19.2\n"
     ]
    }
   ],
   "source": [
    "!pip install pyecharts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "44750717",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyecharts"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c39d5c27",
   "metadata": {},
   "source": [
    "# 2. 使用一个模块（函数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1b4e8cfa",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "3fdd662b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2023, tm_mon=11, tm_mday=12, tm_hour=23, tm_min=18, tm_sec=5, tm_wday=6, tm_yday=316, tm_isdst=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "62b632c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help 可以查看一个  模块  的帮助文档\n",
    "# help(time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "cde33011",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# help 可以查看一个  函数 的帮助文档（使用文档）\n",
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "648d8c59",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world~\n"
     ]
    }
   ],
   "source": [
    "time.sleep(5)\n",
    "print(\"hello world~\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fa44044",
   "metadata": {},
   "source": [
    "# 3. 变量、赋值、数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "81e2ac6c",
   "metadata": {},
   "outputs": [],
   "source": [
    "dog_name = \"豆豆\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "085cd3c0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "豆豆\n"
     ]
    }
   ],
   "source": [
    "print(dog_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "55e268c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "dog_age = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ea9a6f4a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "print(dog_age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "83d8e408",
   "metadata": {},
   "outputs": [],
   "source": [
    "dog_name = \"毛毛\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "0e44891d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "毛毛\n"
     ]
    }
   ],
   "source": [
    "print(dog_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "473af761",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小明 小明\n"
     ]
    }
   ],
   "source": [
    "# 实践\n",
    "name_10001 = \"小明\"\n",
    "\n",
    "name_10002 = name_10001\n",
    "print(name_10001,name_10002)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "a75618d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "name_10001 = \"小兰\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "beed8afa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小兰 小明\n"
     ]
    }
   ],
   "source": [
    "print(name_10001,name_10002)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e4cb855c",
   "metadata": {},
   "source": [
    "# 条件判断 与 循环遍历"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "1c8b1316",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "对不起，你的身份信息不对，无法开门~\n"
     ]
    }
   ],
   "source": [
    "if dog_name == \"花花\":\n",
    "    print(\"欢迎回家~\")\n",
    "else:\n",
    "    print(\"对不起，你的身份信息不对，无法开门~\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "217fd9cb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
